//
//  LGSEdge.h
//  LogicSim
//
//  Created by Jeremy Pereira on 04/04/2012.
//  Copyright (c) 2012 Jeremy Pereira. All rights reserved.
//

#import <Foundation/Foundation.h>

@class LGSNode;
@class LGSName;

/*!
 *  @brief represents a connection between two nodes
 */
@interface LGSEdge : NSObject

/*!
 *  @brief set the bits of an array of edges according to the bit pattern
 *         provided.
 *  @param array array of edges.  If there are more than 32 edges, the most 
 *         significant ones are ignored.
 *  @param bits 32 bit bit pattern
 *  @param affectedNodes any nodes affected by setting the bits will be put in
 *         here.  If this is nil, will be ignored.
 */
+(void) setArray: (NSArray*) array 
      from32Bits: (uint32_t) bits
   affectedNodes: (NSMutableOrderedSet*) affectedNodes;

/*!
 *  @brief turns an array of edge values into a bit pattern.
 *  @param bits array of edges to make into a bit pattern
 *  @return a 32 bit number reflecting the bit pattern
 */
+(uint32_t) make32BitNumberFromEdgeArray: (NSArray*) bits;


/*!
 *  @brief current value of the edge
 */
@property (nonatomic, readonly, assign) bool value;
/*!
 *  @brief input node for this edge
 */
@property (nonatomic, weak) LGSNode *input;
/*!
 *  @brief output node for this edge.
 *
 *  This is a weak property.
 */
@property (nonatomic, weak) LGSNode *output;

/*!
 *  @brief the name of the connection that this is attached to on its input side
 */
@property (nonatomic, copy) LGSName* inputName;
/*!
 *  @brief the name of the connection that this is attached to on its output side
 */
@property (nonatomic, copy) LGSName* outputName;

/*!
 *  @brief a label to know this edge by
 *
 *  This is a weak property.
 */
@property (nonatomic, copy) NSString* label;
/*!
 *  @brief set the value for this edge
 *  @param newValue the new value for the edge
 *  @param affectedNodes a set of nodes to which the output will be added if the
 *                       value actually hanges
 */
-(void) setValue: (bool) newValue affectedNodes: (NSMutableOrderedSet*) affectedNodes;

/*!
 *  @brief a null edge that can be used as a placeholder in collections.
 *  @return a null edge
 */
+(LGSEdge*) null;

@end
